package org.compiere.model;

import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.List;
import java.util.Properties;

import org.compiere.util.DB;
import org.joda.time.DateTime;

public class Mcmspayment extends X_cms_payment 
{
	private static final long serialVersionUID = -4221080569133349707L;

	public Mcmspayment(Properties ctx, ResultSet rs, String trxName) 
	{
		super(ctx, rs, trxName);
	}

    public Mcmspayment (Properties ctx, int cms_payment_ID, String trxName)
    {
      super (ctx, cms_payment_ID, trxName);
    }
    
    public static Mcmspayment[] getOfCMS_Contract(Properties ctx, int CMS_Contract_ID, Timestamp time, String trxName)
	{
		List<Mcmspayment> list = new Query(ctx, I_cms_payment.Table_Name, "CMS_Contract_ID=? AND TO_CHAR(dateAcct,'YYYY-MM') = ?", trxName)
		.setParameters(CMS_Contract_ID, "TO_CHAR("+DB.TO_DATE(time, true)+",'YYYY-MM')")
		.setOnlyActiveRecords(true)
		.list();
		
		String sql = new Query(ctx, I_cms_payment.Table_Name, "CMS_Contract_ID=? AND TO_CHAR(dateAcct,'YYYY-MM') = ?", trxName)
		.setParameters(CMS_Contract_ID, "TO_CHAR("+DB.TO_DATE(time, true)+",'YYYY-MM')")
		.setOnlyActiveRecords(true).getSQL();
		
		Mcmspayment[] retValue = new Mcmspayment[list.size ()];
		list.toArray (retValue);
		return retValue;
	}
}
